package com.xzlf.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.xzlf.dto.ItemDTO;
import org.apache.commons.lang3.StringUtils;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
import java.util.List;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import java.util.List;
import com.xzlf.mapper.TbItemMapper;
import com.xzlf.entity.TbItem;
import com.xzlf.service.TbItemService;
@Service
public class TbItemServiceImpl extends ServiceImpl<TbItemMapper, TbItem> implements TbItemService{

    @Override
    public int updateBatch(List<TbItem> list) {
        return baseMapper.updateBatch(list);
    }
    @Override
    public int updateBatchSelective(List<TbItem> list) {
        return baseMapper.updateBatchSelective(list);
    }
    @Override
    public int batchInsert(List<TbItem> list) {
        return baseMapper.batchInsert(list);
    }

    @Override
    public List<TbItem> list(ItemDTO itemDTO) {
        List<TbItem> list = list(new LambdaQueryWrapper<TbItem>()
                .likeRight(StringUtils.isNotBlank(itemDTO.getTitle()), TbItem::getTitle, itemDTO.getTitle())
                .likeRight(StringUtils.isNotBlank(itemDTO.getSellPoint()), TbItem::getSellPoint, itemDTO.getSellPoint())
                .le(itemDTO.getPrice() > 0L, TbItem::getPrice, itemDTO.getPrice()));
        return list;
    }
}
